//
//  NSObject+QTAssociate.m
//  Pods
//
//  Created by 张俊博 on 16/8/23.
//
//

#import "NSObject+QTAssociate.h"
#import "QTCategoryMacro.h"

QTSYNTH_DUMMY_CLASS(NSObject_QTAssociate)

#if __has_feature(objc_arc)
@implementation __ObjCAscWeakContainer
+ (instancetype)wrapObject:(id)object {
    __ObjCAscWeakContainer *wrapper = [[self alloc] init];
    wrapper._object = object;
    return wrapper;
}
@end
#endif

@implementation NSObject (QTAssociate)

- (void)setAs_dictionary:(NSMutableDictionary *)as_dictionary {
    objc_setAssociatedObject(self, @selector(as_dictionary), as_dictionary, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSMutableDictionary *)as_dictionary {
    NSMutableDictionary *as_dictionary = objc_getAssociatedObject(self, @selector(as_dictionary));
    if (!as_dictionary) {
        as_dictionary = @{}.mutableCopy;
        [self setAs_dictionary:as_dictionary];
    }
    return as_dictionary;
}

@end
